package com.yesep.learn.kafka.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yesep.learn.kafka.common.TOPIC;

@RestController
public class KafkaProducerController {
	private Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private KafkaTemplate<String, String> kafkaTemplate;

	@RequestMapping("send/{msg}")
	public String send(@PathVariable("msg") String msg) {
		logger.info("生产者生产的消息：" + msg);
		kafkaTemplate.send(TOPIC.TEST_TOPIC, msg);
		return "success";
	}

}